<template>
  <div class="app-container">
    <PlatformHeader />
    <div class="main-container" :style="{ height: `calc(100vh - 72px)` }">
      <!-- 左侧面板 -->
      <div
        class="left-panel"
        :class="{ 'hidden': leftPaneSize === 0 }"
        :style="{ width: `${leftPaneSize}%` }"
      >
        <div class="head-container">
          <el-input
            v-model="deptName"
            placeholder="请输入机构名称"
            clearable
            size="small"
            prefix-icon="el-icon-search"
            style="margin-bottom: 20px"
          />
        </div>
        <div class="head-container">
          <el-tree
            :data="deptOptions"
            :props="defaultProps"
            :expand-on-click-node="false"
            :filter-node-method="filterNode"
            ref="tree"
            node-key="id"
            default-expand-all
            highlight-current
            @node-click="handleNodeClick"
          />
        </div>
      </div>

      <!-- 右侧主内容区 -->
      <div class="right-panel">
        <button
          class="toggle-btn"
          @click="toggleLeftPane"
          :style="{ left: leftPaneSize === 0 ? '10px' : `${leftPaneSize}%` }"
        >
          <i class="el-icon-s-fold" v-if="leftPaneSize > 0"></i>
          <i class="el-icon-s-unfold" v-else></i>
        </button>

        <el-col style="height: 100%;display: flex;flex-direction: column;">
          <el-form
            :model="form"
            ref="queryForm"
            size="small"
            :inline="true"
            v-show="showSearch"
            label-width="90px"
            :rules="formRules"
            class="custom-form"
          >
            <el-form-item label="" prop="deptId" required>
              <el-input
                v-model="selectedNodeInfo"
                placeholder="请从左侧选择机构"
                title="请从左侧选择机构"
                readonly
                clearable
                style="width: 220px;background-color: transparent;"
                @focus="handleInputFocus"
              />
            </el-form-item>

            <el-form-item label="" prop="dateRange" required>
              <el-date-picker
                popper-class="custom-select-dropdown"
                v-model="form.dateRange"
                style="width: 260px"
                value-format="yyyy-MM-dd"
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                title="请选择完整的日期范围"
                :picker-options="pickerOptions"
                @change="handleDateChange"
              />
            </el-form-item>

            <el-form-item>
              <el-button
                type="primary"
                icon="el-icon-search"
                size="mini"
                @click="handleQuery"
                class="search-btn action-btn"
                :disabled="!isFormValid"
              >查询</el-button>
              <el-button icon="el-icon-refresh" size="mini" class="reset-btn action-btn" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>

          <!-- 表格容器占满剩余空间 -->
          <div class="table-container">
            <el-table
              v-loading="loading"
              :data="pagedTestPeopleList"
              @selection-change="handleSelectionChange"
              class="custom-table"
              style="width: 100%"
              :span-method="objectSpanMethod"
              :header-cell-style="{height: '60px', padding: '0', 'vertical-align': 'middle'}"
            >
              <el-table-column
                label="地区"
                align="center"
                prop="name"
                width="200"
                header-align="center"
              />

              <!-- 幼儿年龄段 -->
              <el-table-column
                label="幼儿总计"
                align="center"
                prop="youer"
                header-align="center"
              >
                <template #header>
                  <div
                    @click="toggleAgeGroup('children')"
                    style="cursor: pointer; display: flex; align-items: center; justify-content: center; height: 100%;"
                  >
                    <span>{{ expandedAgeGroup === 'children' ? '▼ 幼儿总计' : '▶ 幼儿总计' }}</span>
                  </div>
                </template>
              </el-table-column>

              <!-- 动态添加的幼儿详细年龄组 -->
              <template v-if="expandedAgeGroup === 'children'">
                <el-table-column
                  v-for="(childAge, index) in childAges"
                  :key="'child-' + index"
                  :label="childAge.label"
                  align="center"
                  :prop="childAge.prop"
                  width="120"
                />
              </template>

              <!-- 成年年龄段 -->
              <el-table-column
                label="成年总计"
                align="center"
                prop="chengren"
                header-align="center"
              >
                <template #header>
                  <div
                    @click="toggleAgeGroup('adult')"
                    style="cursor: pointer; display: flex; align-items: center; justify-content: center; height: 100%;"
                  >
                    <span>{{ expandedAgeGroup === 'adult' ? '▼ 成年总计' : '▶ 成年总计' }}</span>
                  </div>
                </template>
              </el-table-column>

              <!-- 动态添加的成年详细年龄组 -->
              <template v-if="expandedAgeGroup === 'adult'">
                <el-table-column
                  v-for="(adultAge, index) in adultAges"
                  :key="'adult-' + index"
                  :label="adultAge.label"
                  align="center"
                  :prop="adultAge.prop"
                  width="120"
                />
              </template>

              <!-- 老年年龄段 -->
              <el-table-column
                label="老年总计"
                align="center"
                prop="laoren"
                header-align="center"
              >
                <template #header>
                  <div
                    @click="toggleAgeGroup('elder')"
                    style="cursor: pointer; display: flex; align-items: center; justify-content: center; height: 100%;"
                  >
                    <span>{{ expandedAgeGroup === 'elder' ? '▼ 老年总计' : '▶ 老年总计' }}</span>
                  </div>
                </template>
              </el-table-column>

              <!-- 动态添加的老年详细年龄组 -->
              <template v-if="expandedAgeGroup === 'elder'">
                <el-table-column
                  v-for="(elderAge, index) in elderAges"
                  :key="'elder-' + index"
                  :label="elderAge.label"
                  align="center"
                  :prop="elderAge.prop"
                  width="120"
                />
              </template>

              <el-table-column
                label="总人数"
                align="center"
                prop="allvalue"
                width="200"
                header-align="center"
              />
            </el-table>
          </div>

          <!-- 分页器 -->
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30, 50]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            class="pagination"
          />
        </el-col>
      </div>
    </div>
  </div>
</template>

<script>
import { deptTreeSelect } from "@/api/system/user";
import PlatformHeader from '../../../components/PlatformHeader/index.vue';
import { gettestlogdetails } from "@/api/monitormanage/testpeoplelog";

export default {
  name: "Testpeople",
  components: { PlatformHeader },
  data() {
    const validateDateRange = (rule, value, callback) => {
      if (!value || value.length !== 2) {
        callback(new Error('请选择完整的日期范围'));
      } else {
        const startDate = new Date(value[0]);
        const endDate = new Date(value[1]);
        if (startDate.getFullYear() !== endDate.getFullYear()) {
          callback(new Error('开始日期和结束日期必须在同一年内'));
        } else {
          callback();
        }
      }
    };
   // 获取默认日期范围
    const getDefaultDateRange = () => {
      const today = new Date();
      const currentYear = today.getFullYear();
      const startDate = `${currentYear}-01-01`;
      const endDate = today.toISOString().split('T')[0];
      return [startDate, endDate];
    };

    const defaultRange = getDefaultDateRange();
    return {
      leftPaneSize: 0,
      form: {
        deptId: undefined,
        dateRange: defaultRange,
        starttime: defaultRange[0],
        endtime: defaultRange[1]
      },
      loading: false,
      showSearch: true,
      deptOptions: undefined,
      deptName: undefined,
      startYear: null,
      defaultProps: {
        children: "children",
        label: "label"
      },
      formRules: {
        deptId: [
          { required: true, message: '请选择机构', trigger: ['change', 'blur'] }
        ],
        dateRange: [
          { validator: validateDateRange, trigger: ['change', 'blur'] }
        ]
      },
      selectedNodeInfo: '',

      // 当前展开的年龄组（null表示全部收起）
      expandedAgeGroup: null,

      // 年龄组配置
      childAges: [
        { label: '3岁', prop: 'youersan' },
        { label: '3.5岁', prop: 'youersanwu' },
        { label: '4岁', prop: 'youersi' },
        { label: '4.5岁', prop: 'youersiwu' },
        { label: '5岁', prop: 'youerwu' },
        { label: '5.5岁', prop: 'youerwuwu' },
        { label: '6岁', prop: 'youerliu' },
        { label: '6.5岁', prop: 'youerliuwu' }
      ],
      adultAges: [
        { label: '20-24', prop: 'chengrener' },
        { label: '25-29', prop: 'chengrenerwu' },
        { label: '30-34', prop: 'chengrensan' },
        { label: '35-39', prop: 'chengrensanwu' },
        { label: '40-44', prop: 'chengrensi' },
        { label: '45-49', prop: 'chengrensiwu' },
        { label: '50-54', prop: 'chengrenwu' },
        { label: '55-59', prop: 'chengrenwuwu' }
      ],
      elderAges: [
        { label: '60-64', prop: 'laorenliu' },
        { label: '65-69', prop: 'laorenliuwu' },
        { label: '70-74', prop: 'laorenqi' },
        { label: '75-79', prop: 'laorenqiwu' }
      ],

      testPeopleList: [],
      pagedTestPeopleList: [],
      ids: [],
      single: true,
      multiple: true,

      // 分页相关
      currentPage: 1,
      pageSize: 10,
      total: 0,
      // 日期选择器配置
      pickerOptions: {
        disabledDate: (time) => {
          // 如果没有选择开始日期或者已经清除了选择，只禁用未来日期
          if (!this.startYear) {
            return time.getTime() > Date.now();
          }

          // 如果已经选择了开始日期，限制只能选择同一年份
          const timeYear = time.getFullYear();
          return time.getTime() > Date.now() || timeYear !== this.startYear;
        },
        onPick: ({ maxDate, minDate }) => {
          if (minDate) {
            // 保存选中的开始日期年份
            this.startYear = minDate.getFullYear();
          } else {
            // 如果没有选择日期，清除年份限制
            this.startYear = null;
          }
        },
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        },{
          text: '本年至今', //
          onClick(picker) {
            const end = new Date();
            const start = new Date(end.getFullYear(), 0, 1);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
    };
  },
  computed: {
    isFormValid() {
      return this.form.deptId && this.form.dateRange;
    }
  },
  watch: {
    deptName(val) {
      this.$refs.tree.filter(val);
    }
  },
  methods: {
    getDeptTree() {
      deptTreeSelect().then(response => {
        // 过滤掉 type 为 "1" 的节点
        const filterType1Nodes = (nodes) => {
          return nodes.filter(node => {
            // 如果当前节点的 type 为 "1"，则过滤掉
            if (node.type === "1") {
              return false;
            }
            // 递归处理子节点
            if (node.children && node.children.length) {
              node.children = filterType1Nodes(node.children);
            }
            return true;
          });
        };

        // 应用过滤
        //this.deptOptions = response.data;
        this.deptOptions = filterType1Nodes(response.data);
        this.form.deptId = response.data[0].id
        this.selectedNodeInfo = response.data[0].label
        // 确保数据加载完成后执行搜索
        this.$nextTick(() => {
          this.handleQuery();
        });

      });
    },
    toggleLeftPane() {
      this.leftPaneSize = this.leftPaneSize === 0 ? 16 : 0;
    },
    handleInputFocus() {
      this.leftPaneSize = 16;
    },
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    handleNodeClick(data) {
      this.form.deptId = data.id;
      this.selectedNodeInfo = `${data.label} `;
      this.leftPaneSize = 0;
      this.$refs.queryForm.clearValidate(['deptId']);
    },
    handleDateChange(val) {
      if (val && val.length === 2) {
        this.form.starttime = val[0];
        this.form.endtime = val[1];
        const startDate = new Date(val[0]);
        const endDate = new Date(val[1]);
        if (startDate.getFullYear() !== endDate.getFullYear()) {
          this.$message.error('错误：开始日期和结束日期必须在同一年内！');
          this.form.dateRange = [];
          this.form.starttime = undefined;
          this.form.endtime = undefined;
          this.startYear = null;
        } else {
          this.startYear = startDate.getFullYear();
          this.$refs.queryForm.clearValidate(['dateRange']);
        }
      } else {
        this.form.starttime = undefined;
        this.form.endtime = undefined;
        this.form.dateRange = null;
        this.startYear = null;
      }
    },

    // 修改后的年龄组展开/折叠方法 - 互斥展开
    toggleAgeGroup(group) {
      if (this.expandedAgeGroup === group) {
        // 如果点击的是当前已展开的组，则收起
        this.expandedAgeGroup = null;
      } else {
        // 否则展开点击的组
        this.expandedAgeGroup = group;
      }
    },

    // 计算列总计
    getColumnTotal(data, prop) {
      if (!data || data.length === 0) return 0;
      return data.reduce((sum, item) => sum + (item[prop] || 0), 0);
    },

    // 分页处理
    handleSizeChange(val) {
      this.pageSize = val;
      this.updatePagedData();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.updatePagedData();
    },
    updatePagedData() {
      const start = (this.currentPage - 1) * this.pageSize;
      const end = start + this.pageSize;
      this.pagedTestPeopleList = this.testPeopleList.slice(start, end);
    },

    // 合并单元格方法
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      // 处理表头合并
      if (rowIndex === 0) {
        if (columnIndex === 0) {
          return {
            rowspan: 1,
            colspan: 1
          };
        }
      }
    },

    handleQuery() {
      this.$refs.queryForm.validate(valid => {
        if (valid) {
          this.loading = true;
          const queryParams = {
            deptid: this.form.deptId,
            starttime: this.form.starttime,
            endtime: this.form.endtime,
            year: this.form.starttime.substring(0, 4),
          };

          gettestlogdetails(queryParams).then(response => {
            this.testPeopleList = response;
            this.total = this.testPeopleList.length;
            this.updatePagedData();
            this.loading = false;
          }).catch(() => {
            this.loading = false;
          });
        }
      });
    },
    resetQuery() {
      this.form = {
        deptId: undefined,
        dateRange: null,
        starttime: undefined,
        endtime: undefined
      };
      this.selectedNodeInfo = '';
      this.startYear = null;
      this.testPeopleList = [];
      this.pagedTestPeopleList = [];
      this.total = 0;
      this.currentPage = 1;
      // 重置所有年龄组为收起状态
      this.expandedAgeGroup = null;
      this.$refs.tree.setCurrentKey(null);
      this.$nextTick(() => {
        this.$refs.queryForm.clearValidate();
      });
    },
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
  },
  created() {
    this.getDeptTree();
  }
};
</script>

<style scoped lang="scss">
/* 保持原有样式不变 */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: url('../../assets/images/bgn.png');
  background-size: 100% 100%;
  padding: 16px;
  box-sizing: border-box;
  padding-top: 0;
}

.main-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  padding: 10px;
  padding-top: 20px;
}

.left-panel {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background-color: #0160FA;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 10;
  transition: width 0.3s ease;
  overflow: auto;
  padding: 16px;
  box-sizing: border-box;
}

.left-panel.hidden {
  width: 0 !important;
  padding: 0;
}

.right-panel {
  width: 100%;
  height: 100%;
  padding-left: 0;
  transition: padding-left 0.3s ease;
  box-sizing: border-box;
  overflow: auto;
}

.toggle-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 30px;
  background-color: rgba(0,128,255,0.3);
  border: 1px solid #0080ff;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: left 0.3s ease;
}

.toggle-btn i {
  color: #fff;
  font-size: 10px;
}

.custom-form {
  .el-form-item {
    margin-right: 20px;
    margin-bottom: 18px;
  }

  .el-form-item__label {
  }

  .el-input, .el-select, .el-date-editor {
    width: 220px;
  }

  .el-date-editor.el-input, .el-date-editor.el-input__inner {
    width: 260px;
  }
}

::v-deep .el-tree {
  background: #0080FF;
  color: #fff;
  border-radius: 8px;
}

::v-deep .el-tree-node__content:hover {
  background-color: #0879e9;
}

::v-deep .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
  background-color: #0879e9;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  border-radius: 4px;
  background-color: rgba(240, 240, 240, 0.3);
}

::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background-color: rgba(0, 128, 255, 0.5);
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 128, 255, 0.7);
}

::v-deep .el-input .el-input__inner {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid #00CCFE;
  border-radius: 6px;
  color: #f0f0f0;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  font-size: 14px;
}

::v-deep .el-input__inner::placeholder {
  color: #fff !important;
}

::v-deep .el-input .el-input__inner:focus {
  border-color: #409eff;
  box-shadow: 0 0 5px rgba(64, 158, 255, 0.6);
  background-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

::v-deep .el-form-item .el-button {
  border-radius: 22px;
  font-weight: 600;
  font-size: 15px;
  padding: 10px 28px;
  transition: all 0.3s ease;
  box-shadow: 0 3px 8px rgba(66, 133, 244, 0.3);
}

::v-deep .el-form-item .el-button--primary {
  background: linear-gradient(45deg, #409eff, #66b1ff);
  border: none;
  color: #fff;
  box-shadow: 0 5px 14px rgba(64, 158, 255, 0.6);
}

::v-deep .el-form-item .el-button--primary:hover {
  background: linear-gradient(45deg, #66b1ff, #409eff);
  box-shadow: 0 7px 18px rgba(64, 158, 255, 0.8);
}

::v-deep .el-date-editor {
  background-color: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid #00CCFE !important;
  border-radius: 6px;
  color: #f0f0f0 !important;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

::v-deep .el-date-editor:hover {
  border-color: #409eff !important;
}

::v-deep .el-date-editor .el-range-input {
  background-color: transparent !important;
  color: #fff !important;
}

::v-deep .el-date-editor .el-range-separator {
  color: rgba(255, 255, 255, 0.8) !important;
}

::v-deep .el-date-editor .el-range-input::placeholder,
::v-deep .el-date-editor input::placeholder {
  color: #fff !important;
}

/* 表格容器占满空间 */
.table-container {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: auto;
}

::v-deep .el-table {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: transparent;
  border-radius: 0px;
  overflow: hidden;
  border: none;
  width: 100%;
}

::v-deep .el-table::before {
  height: 0;
}

::v-deep(.el-table__header-wrapper) .el-table__header th {
  background-color: #f7e797;
  font-weight: bold;
  background: #f7e797;
  color: #1e4f91;
  font-size: 18px;
  border: none;
}

::v-deep(.el-table__header .el-table__cell) {
  background-color: #f7e797;
  border-right: none !important;
}

::v-deep(.el-table th.el-table__cell.is-leaf) {
  border-bottom: none;
}

::v-deep(.el-table .el-table__cell) {
  padding: 8px 0;
}

::v-deep(.el-table__body-wrapper) {
  flex: 1;
  overflow: auto;
  border-radius: 0 0 12px 12px;
}

::v-deep .el-table__body {
  border-collapse: separate !important;
  border-spacing: 0 5px !important;
}

::v-deep .el-table__row {
  td {
    border: none;
    color: #000;
    font-size: 18px;
    padding: 12px 8px;
  }
}

::v-deep .el-table__row:nth-child(odd) {
  background: linear-gradient(90deg, #99e8ff, #4f85ff);
}

::v-deep .el-table__row:nth-child(even) {
  background: linear-gradient(90deg, #4f85ff, #99e8ff);
}

::v-deep .el-table__body tr:hover > td {
  background: #9ef7c5 !important;
}

::v-deep .el-table .cell {
  line-height: 35px;
  height: 35px;
}

::v-deep .el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell {
  background-color: transparent;
}

/* 分页栏样式 */
.pagination {
  margin-top: 16px;
  padding: 10px 0;
  background-color: transparent;
  border-radius: 8px;
  display: flex;
  justify-content: flex-end;
}
::v-deep .el-pager li{
  background: #1890ff;
  color: #fff;
}
::v-deep .el-pagination {
  color: #fff !important;
}

::v-deep .el-pagination__total,
::v-deep .el-pagination__jump {
  color: #fff !important;
}

::v-deep .el-pagination.is-background .btn-next,
::v-deep .el-pagination.is-background .btn-prev,
::v-deep .el-pagination.is-background .el-pager li {
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: #409eff;
  color: #fff;
}

::v-deep .el-pagination.is-background .el-pager li:not(.disabled):hover {
  color: #409eff;
}

::v-deep .el-input__clear {
  color: #a8c0ff;
}

::v-deep .el-input__clear:hover {
  color: #409eff;
}

/* 关键样式：调整输入框高度为36px */
::v-deep .custom-form .el-input__inner {
  height: 36px!important;
  line-height: 36px!important;
}
::v-deep .el-pagination.is-background .el-pager li{
  background-color:#568eff;
  color: #fff!important;
}
::v-deep .el-table thead.is-group th.el-table__cell {
  background: #f7e797;
}

/* 新增样式：表头折叠/展开效果 */
::v-deep .el-table__header-wrapper .el-table__cell .cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

::v-deep .el-table__header .el-table__cell {
  position: relative;
}

::v-deep .el-table__header .el-table__cell:after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  background-color: rgba(30, 79, 145, 0.3);
}
::v-deep .el-table--border .el-table__cell{
  border:1px solid transparent;
}
/* 调整表单里的按钮间距 */
::v-deep .el-form-item .el-button {
  margin-left: 12px; /* 你可以改成 16px 更宽松 */
}
/* 按钮通用样式（不改尺寸） */
::v-deep .el-form-item .action-btn {
  border-radius: 20px; /* 圆润 */
  font-weight: 600;
  border: none;
  transition: all 0.3s ease;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

/* 悬浮时按钮微微上浮 + 光晕 */
::v-deep .el-form-item .action-btn:hover {
  transform: translateY(-2px);
}

/* 搜索按钮 - 宝石蓝渐变 */
::v-deep .el-form-item .search-btn {
  background: linear-gradient(135deg, #b4cdeb, #2f6bcc);
  color: #fff;
}
::v-deep .el-form-item .search-btn:hover {
  background: linear-gradient(135deg, #5aa2f8, #3a8ef6);
  box-shadow: 0 6px 14px rgba(58, 142, 246, 0.5);
}

/* 重置按钮 - 高级灰蓝 */
::v-deep .el-form-item .reset-btn {
  background: linear-gradient(135deg, #df9f3f, #edc73d);
  color: #fff;
}
::v-deep .el-form-item .reset-btn:hover {
  background: linear-gradient(135deg, #ffcc80, #ffb74d);
  box-shadow: 0 6px 14px rgba(255, 183, 77, 0.5);
}

/* 新增样式：确保表头单元格高度一致 */
::v-deep .el-table th.el-table__cell {
  height: 60px;
  padding: 0;
}

/* 新增样式：确保表头文字垂直居中 */
::v-deep .el-table__header .el-table__cell .cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 18px;
}
::v-deep .el-table thead.is-group th.el-table__cell {
  background: #f7e797;
}
::v-deep .el-table .el-table__header-wrapper th, .el-table .el-table__fixed-header-wrapper th {
  background: #f7e797;
  //font-size: 20px;
}
/* 为表格行添加圆角 */
::v-deep .el-table__body tr {
  border-radius: 10px !important;
  overflow: hidden;
  display: table-row;
}

/* 调整第一个和最后一个单元格的圆角 */
::v-deep .el-table__body tr td:first-child {
  border-radius: 10px 0 0 10px !important;
}

::v-deep .el-table__body tr td:last-child {
  border-radius: 0 10px 10px 0 !important;
}
/* 表头圆角设置 */
::v-deep .el-table__header th:first-child {
  border-radius: 10px 0 0 10px !important;
}

::v-deep .el-table__header th:last-child {
  border-radius: 0 10px 10px 0 !important;
  background: red;
}
/* 确保表头没有分隔线干扰圆角效果 */
::v-deep .el-table__header th.el-table__cell {
  border-right: none !important;
}

::v-deep .el-table__header-wrapper {
  border-radius: 10px;
}
</style>
